package com.sks.web.action.news;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.stereotype.Controller;

import com.sks.bean.PageView;
import com.sks.bean.QueryResult;
import com.sks.bean.pojo.Feature;
import com.sks.service.news.FeatureService;
import com.sks.web.action.BasicAction;
import com.sks.web.action.privilege.Permission;
import com.sks.web.formbean.news.FeatureForm;



/**
 * 专题分页列表
 * @author yuanjiayuan
 *
 */
@Controller("/cms/feature/list")
public class FeatureListAction extends BasicAction{

	@Resource(name="featureServiceBean")
	private FeatureService featureService;

	

	@Permission(module="info", privilege="view")
	public ActionForward list(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		FeatureForm formbean = (FeatureForm) form;
		
		StringBuffer jpql = new StringBuffer("");
		List<Object> params = new ArrayList<Object>();
		
		PageView<Feature> pageView = new PageView<Feature>(15, formbean.getPage());//初始化分页类		
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();	
		orderby.put("featureId", "asc");	
		QueryResult<Feature> rs = featureService.getScrollData(
				pageView.getFirstResult(), pageView.getMaxresult(), jpql.toString(),
				params.toArray(), orderby);
		pageView.setQueryResult(rs);
		request.setAttribute("pageView", pageView);
		
		return mapping.findForward(LIST);
	}

}
